home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / network / lattice / portlib.lzh / PORTLIB / GETHOSTI.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  500 b   |  25 lines

  1. /*
  2.  * u_long gethostid (void) -- get 32 bit host identification number.
  3.  */
  4.  
  5. #include <sys/types.h>
  6. #include <sys/socket.h>
  7. #include <netinet/in.h>
  8. #include <arpa/inet.h>
  9. #include <netdb.h>
  10. #include <support.h>
  11. #include "portlib.h"
  12.  
  13. u_long
  14. gethostid (void)
  15. {
  16.     struct hostent *hp;
  17.     static char hname[MAXHOSTNAMELEN];
  18.  
  19.     if (gethostname (hname, sizeof (hname) < 0))
  20.         return INADDR_NONE;
  21.     if (!(hp = gethostbyname (hname)))
  22.         return INADDR_NONE;
  23.     return *(u_long *)hp->h_addr;
  24. }
  25.